/*

 ** 前端封装API接口模块 ：用户(User) 模块

 */

import http from "@/utils/request";

// 用户登录

export function loginAPI(params) {

	return http.request({

		url: "/user/login",

		method: "post",

		data: params,

	});

}



// 用户退出登录

export function logoutAPI() {

	return http.request({

		url: "/user/logout",

		method: "get",

	});

}

// 用户注册

export function registerAPI(params) {

	return http.request({

		url: "/user/register",

		method: "post",

		data: params,

	});

}



// 用户信息 By用户Id

export function getDetailByIdAPI(id) {

	return http.request({

		url: "/user/detail",

		method: "get",

		params: {

			id

		},

	});

}



// 用户编辑 By 用户ID

export function updateAPI(params) {

	return http.request({

		url: "/user/update",

		method: "post",

		data: params,

	});

}



// 用户修改密码 By用户Id

export function updatePwdAPI(params) {

	return http.request({

		url: "/user/updatePwd",

		method: "post",

		data: params,

	});

}



// 上传用户头像

export function uploadAvatarAPI(file) {

	let formData = new FormData();

	formData.append("avatar", file.file);

	return http.post("/upload/avatar", formData, {

		headers: {

			'enctype': 'multipart/form-data'

		},

	});

}
